package com.jd.jr.pay.demo.action;

import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jd.jr.pay.demo.model.CreateOrderVO;
import com.jd.jr.pay.demo.model.OrderListVO;
import com.jd.jr.pay.demo.model.UserInfoVO;
import com.jd.jr.pay.demo.util.MD5Util;
import com.jd.jr.pay.demo.util.PropertyUtils;

/**
 */
@Controller
public class OrderListAction {

	/**
	 * @param httpServletRequest
	 * @return
	 * 查询用户账单
	 */
	@RequestMapping(value = "/orderListStart.htm")
	public String orderListStart(HttpServletRequest httpServletRequest) {
		httpServletRequest.setAttribute("mercId", PropertyUtils.getProperty("9f.mercId"));
		httpServletRequest.setAttribute("mblNo", PropertyUtils.getProperty("9f.user.uMblNo"));
		httpServletRequest.setAttribute("pageUrl", PropertyUtils.getProperty("9f.orderListPage"));
		return "orderListStart";
	}
	/**
	 * @param map
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * 拼接form提交信息的参数，并传递给自提交的页面中
	 */
	@RequestMapping(value = "/orderListAuto.htm")
	public String orderListAuto(OrderListVO orderListVO,HttpServletRequest request, HttpServletResponse response) throws Exception {
		//生成验签
		String paySignString = getOrderListVOSign(orderListVO, PropertyUtils.getProperty("9f.salt"));
//		orderListVO.setHmac(MD5Util.md5(paySignString).toLowerCase());
		
		
		request.setAttribute("orderListVO", orderListVO);
		request.setAttribute("Url", PropertyUtils.getProperty("9f.orderList"));

		return "orderListAuto";
	}
	/**
	 * @param httpServletRequest
	 * @return
	 * 查询用户账单
	 */
	@RequestMapping(value = "/orderListPage.htm")
	public String orderListPage(HttpServletRequest httpServletRequest) {
		return "orderListFinish";
	}
	/**
	 * @param createOrderVO
	 * @param key
	 * @return
	 * 拼接待sign的字符串
	 */
	public String getOrderListVOSign(OrderListVO orderListVO,String key){
		return orderListVO.getMblNo()+
		orderListVO.getCarNo()+
		orderListVO.getMercId()+
		orderListVO.getPageUrl()+
		key;
	}

}
